# Create your views here.
from django.http import HttpResponse

from rtve.core.models import Show
from rtve.feed.models import Feed

def createFeed(request):
    shows = request.POST.getlist('checkedShows[]')
    (f,new) = Feed.objects.get_or_create(hash=",".join(shows))
    if (new):
        f.save()
    else:
        f.shows.clear()

    for show in shows:
        show = Show.objects.get(id=int(show)) 
        f.shows.add(show)
    f.save()
    return HttpResponse("http://%s" % request.META['SERVER_NAME'] + '/feeds/shows/' + str(f.id) + '/')
 
